<template>
    <view>
        <!-- parse <include src="../component/navigationBar.wxml"></include> -->
        <block>
            <view class="navigationBox" :style="'padding-top:' + nTop + 'px;height:' + nHeight + 'px;line-height:' + nHeight + 'px;--color:' + color + ';'">
                <view class="nBar" :style="'height:' + nHeight + 'px;top:' + nTop + 'px'">
                    <navigator class="ico" hoverClass="none" :openType="pages.length == 1 ? 'switchTab' : 'navigateBack'" :url="pages.length == 1 ? '/pages/index/index4' : ''">
                        {{ pages.length == 1 ? '' : '' }}
                    </navigator>
                    <view class="title">{{ nTitle }}</view>
                </view>
            </view>
        </block>
        <scroll-view
            @refresherrefresh="onPullDownRefresh"
            @scroll="binnd_scroll_index"
            @scrolltolower="onReachBottom"
            class="yuanfen_list"
            :enableBackToTop="true"
            :enableFlex="true"
            lowerThreshold="300"
            :refresherEnabled="true"
            :refresherTriggered="triggered"
            :scrollTop="scrolltopNum_index"
            :scrollWithAnimation="true"
            :scrollY="true"
            :style="'margin-top:' + nTH + 'px;height:-webkit-calc(100vh - ' + nTH + 'px);--color:' + color + ';--rgbcolor:' + rgbcolor + ';'"
        >
            <block v-if="LIST.length > 0" v-for="(dl, index) in LIST" :key="index">
                <navigator :url="'/pages/yuanfen/yuanfen_detail?id=' + item.fid" v-for="(item, index1) in dl" :key="index1">
                    <view class="h3">{{ item.title }}</view>

                    <view :class="'ifbm' + (item.ifbm == 1 ? ' ifbmed' : '')">{{ item.ifbm == 1 ? '已参与' : '未参与' }}</view>

                    <view class="pic">
                        <image mode="aspectFill" :src="item.path_b"></image>
                    </view>

                    <view class="dl">
                        <view class="dd">
                            <image mode="aspectFill" :src="item3" v-for="(item3, index2) in item.bmulist" :key="index2"></image>
                            <view class="partyflag">进入</view>
                        </view>
                    </view>

                    <view class="djs">
                        本期参与嘉宾
                        <text class="span ico"> {{ item.bmnum }}人参与　　 人气{{ item.click }}</text>
                    </view>
                </navigator>

                <view class="blank" style="width: 100%; height: 20rpx">　</view>
            </block>
            <view class="nodata" v-if="huxuan_nodata && LIST.length == 0">
                <image mode="aspectFit" src="/static/res/img/nodata.png"></image>
                暂无内容　
                <text @tap="nodatabackFn" data-sokind="default" :style="'color:' + color">返回</text>
            </view>
            <view class="loading" v-if="loading_flag">
                <image class="loading_ico" src="/static/res/img/loading_ico.svg" v-if="loading_ico_flag"></image>
                <text>{{ loading_str }}</text>
            </view>
        </scroll-view>
    </view>
</template>
<script module="WXS" lang="wxs" src="@/res/www.a9a.cn.wxs"></script>
<script>
var t;
var a;
var n = require('../../@babel/runtime/helpers/defineProperty');
var i = require('../../res/www.a9a.cn.js');
var app = getApp();
var o = 2;
var s = true;
export default {
    data() {
        return {
            nTitle: '',
            triggered: true,
            loading_flag: false,
            loading_ico_flag: false,
            loading_str: '拼命加载中',
            color: '',
            rgbcolor: '',
            LIST: [],
            huxuan_nodata: false,
            SO: '',
            SHARE: '',
            nTop: '',
            nHeight: '',
            pages: [],
            scrolltopNum_index: 0,
            nTH: '',
            dl: []
        };
    },
    onLoad: function (t) {
        var that = this;
        app.globalData.get_config('_ZEAI').then(function (t) {
            that.setData({
                color: app.globalData._ZEAI.color,
                rgbcolor: i.c16_rgb(app.globalData._ZEAI.color)
            });
            that.init();
        });
        app.globalData.get_navigationBarTopHeight(that);
    },
    onShow: function () {},
    onPullDownRefresh: function () {
        var that = this;
        uni.vibrateShort({
            type: 'heavy'
        });
        setTimeout(function () {
            a = '';
            that.setData({
                triggered: false,
                loading_flag: false,
                loading_str: '拼命加载中',
                LIST: [],
                huxuan_nodata: false
            });
            that.setloading('end', '拼命加载中');
            o = 2;
            that.init();
        }, 500);
    },
    onReachBottom: function () {
        var r = this.LIST;
        var that = this;
        if (s) {
            s = false;
            that.setloading('start', '拼命加载中');
            var g = {
                submitok: 'yuanfen',
                p: o,
                openid: t.openid
            };
            i.empty(a) || (g = JSON.parse((JSON.stringify(g) + JSON.stringify(index_par)).replace(/}{/, ',')));
            app.globalData.ajax({
                url: 'yuanfen.php',
                data: g,
                success: function (t) {
                    if (1 == t.flag) {
                        var a = r.length;
                        if (t.LIST.length < 1) {
                            that.setloading('end', '已全部加载完毕');
                            return void (s = false);
                        }
                        that.setData(n({}, 'LIST[' + a + ']', t.LIST));
                        o += 1;
                        s = true;
                    } else {
                        uni.showToast({
                            title: t.msg,
                            icon: 'none',
                            mask: true
                        });
                    }
                    that.setloading('end', '上拉加载更多');
                }
            });
        }
    },
    onShareAppMessage: function (t) {
        return {
            imageUrl: this.SHARE.imgurl,
            title: this.SHARE.title,
            path: '/pagesA/yuanfen/yuanfen'
        };
    },
    onShareTimeline: function () {
        return {
            imageUrl: this.SHARE.imgurl,
            title: this.SHARE.title,
            query: '',
            path: '/pagesA/yuanfen/yuanfen'
        };
    },
    methods: {
        init: function () {
            var that = this;
            uni.showLoading({
                title: '拼命加载中...',
                mask: true
            });
            s = false;
            var r = {
                submitok: 'yuanfen',
                openid: (t = uni.getStorageSync('COOK_U')).openid
            };
            i.empty(a) || (r = JSON.parse((JSON.stringify(r) + JSON.stringify(a)).replace(/}{/, ',')));
            app.globalData.ajax({
                url: 'yuanfen.php',
                data: r,
                success: function (t) {
                    var a;
                    if (1 == t.flag) {
                        if (0 == t.LIST.length) {
                            that.setData({
                                LIST: [],
                                SO: t.SO,
                                huxuan_nodata: true,
                                SHARE: t.SHARE,
                                nTitle: t.nTitle
                            });
                        } else {
                            that.setData((n((a = {}), 'LIST[0]', t.LIST), n(a, 'SO', t.SO), n(a, 'SHARE', t.SHARE), n(a, 'nTitle', t.nTitle), a));
                        }
                    } else {
                        uni.showToast({
                            title: t.msg,
                            icon: 'none',
                            mask: true
                        });
                    }
                    s = true;
                    uni.hideLoading();
                }
            });
        },

        blankFn: function () {},

        nodatabackFn: function (t) {
            a = '';
            this.setData({
                loading_flag: false,
                loading_str: '拼命加载中',
                LIST: [],
                huxuan_nodata: false
            });
            o = 2;
            this.init();
        },

        setloading: function (t, a) {
            'start' == t
                ? this.setData({
                      loading_flag: true,
                      loading_ico_flag: true,
                      loading_str: a
                  })
                : this.setData({
                      loading_flag: false,
                      loading_ico_flag: false,
                      loading_str: a
                  });
        },

        binnd_scroll_index: function (t) {},

        onPullDownRefresh() {
            console.log('占位：函数 onPullDownRefresh 未声明');
        },

        onReachBottom() {
            console.log('占位：函数 onReachBottom 未声明');
        }
    }
};
</script>
<style>
@import './yuanfen.css';
</style>
